﻿using System;
using System.Data.Odbc;

namespace Gencode.Common.SQL
{
	public class DatabaseConection
	{
		/// <summary>
		/// "DSN="DSNName;UID=userid/sa;PWD=password;Database=database;"
		/// </summary>
		public static string ODBCConnetionString
		{
			get;
			set;
		}

		/// <summary>
		/// OdbcConnection object
		/// </summary>
		public static OdbcConnection ODBCConnection
		{
			get;
			set;
		}

		public static bool InitOdbcConnection()
		{
			bool retVal = true;

			if (ODBCConnetionString == string.Empty)
				return false;

			try
			{
				ODBCConnection = new OdbcConnection(ODBCConnetionString);
			}
			catch (OdbcException)
			{
				retVal = false;
			}
					
			return retVal;
		}
	}
}
